function mark_user(marked_user_id,type,is_login)
{
	if(!is_login)
    	return false;
	
    if(type=='收听')
        type='mark';
    else if(type=='取消收听')
        type='cancel_mark';
    
	var url=BASE_HOSTPATH+"/dr-includes/dr-ajax-mark-user.php";
	var xmlhttp=false;
	if(window.ActiveXObject)
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	else if(window.XMLHttpRequest)
		xmlhttp=new XMLHttpRequest();
	if(!xmlhttp)
	{
		alert("不能创建XMLHTTP实例");
		return false;
	}

	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			var msg=xmlhttp.responseText;
			if(msg==1)
			{
				if(type=='mark')
			    {
					$(document).ready(function(){
						$("input"+".user-"+marked_user_id).val('取消收听');
					});
			        //document.getElementById('user-'+marked_user_id).value='取消收听';
			    }
			    else if(type=='cancel_mark')
			    {
			    	$(document).ready(function(){
						$("input"+".user-"+marked_user_id).val('收听');
					});
			         //document.getElementById('user-'+marked_user_id).value='收听';
			    }
    		}
			else
    			alert(msg);
			
		}
	}

	result="marked_user_id="+marked_user_id+"&mark_type="+type;
	result+="&nocache="+new Date().getTime();
	//alert(result);
	xmlhttp.send(result);
}

function search_user(match_str,is_login,user_id)
{
	if(match_str.length<1)
	{
		document.getElementById("users").style.display='';
		document.getElementById("users-search").style.display='none';
		return false;
	}
	else
	{
		document.getElementById("users").style.display='none';
		document.getElementById("users-search").style.display='';	
	}
	var url=BASE_HOSTPATH+"/dr-includes/dr-ajax-search-user.php";
	var xmlhttp=false;
	if(window.ActiveXObject)
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	else if(window.XMLHttpRequest)
		xmlhttp=new XMLHttpRequest();
	if(!xmlhttp)
	{
		alert("不能创建XMLHTTP实例");
		return false;
	}

	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			var msg=xmlhttp.responseText;
			//alert(msg);
			if(msg=='0')
			{
				document.getElementById("users").style.display='';
				return false;
			}
			else
			{
				var user=eval("("+msg+")");
				var users=user['users'];
				var input='<table>';
				input+='<tr><th>用户名</th><th>积分</th></tr>';
				for(i=0;i<users.length;i++)
				{
					
					input+='<div id="user-summary-'+users[i].user_id+'" class="user-summary">';
					input+='<div class="user">';
					input+='<tr>';
					input+='<td><a href="'+BASE_HOSTPATH+'dr-admin/dr-page-userinfo.php?uid='+users[i].user_id+'" title="查看user信息">'+users[i].username+'</a></td>';
					input+='<td>'+users[i].points+'</td>';
					input+='<td><div class="userlisten">';
					if(is_login)
					{
						if(users[i].user_id!=user_id)
						{
							if(users[i].is_marked==true)
								input+='<span><input id="user-search-'+users[i].user_id+'" class="user-'+users[i].user_id+'" type="button" value="取消收听" onclick="mark_user('+users[i].user_id+',value,'+is_login+')" /></span>';
							else
								input+='<span><input id="user-search-'+users[i].user_id+'" class="user-'+users[i].user_id+'" type="button" value="收听" onclick="mark_user('+users[i].user_id+',value,'+is_login+')" /></span>';
						}
					}
					input+='</div></td></tr></div></div>';
					
				}
				
				input+='</table>';
				
				document.getElementById("users-search").innerHTML=input;
				
			  }
		  }
	
	}

	result="match_str="+match_str;
	result+="&nocache="+new Date().getTime();
	xmlhttp.send(result);
}